Ubuntu文本处理:cat命令查看文件内容

cat是Ubuntu系统基础文本处理命令,源自“concatenate”,核心用于查看/合并文件内容。基本语法`cat 文件名`即可显示文件内容(如查看test.txt)。 常用选项增强功能:-n显示所有行号(含空行),-b仅非空行标序号,-s合并连续空行。多文件处理时,可同时查看多个文件(如`cat file1 file2`),或用`>`重定向合并到新文件(如`cat a.txt b.txt > new.txt`)。 注意事项:文件不存在会报错需检查路径;权限不足用`sudo`;`>`重定向会覆盖目标文件,建议备份或改用`>>`追加。 cat虽简单但实用,通过练习基础操作(如测试不同选项、多文件合并),可快速掌握其灵活应用。

Read More
快速上手:Ubuntu mkdir创建文件夹

本文介绍Ubuntu系统中创建目录的基础命令`mkdir`。`mkdir`(make directory缩写)用于创建空目录,是组织文件的必备工具。基本用法:在当前目录创建单个文件夹,命令格式为`mkdir 文件夹名称`(如`mkdir projects`)。 如需在指定路径(相对或绝对路径)创建,直接指定路径即可(如`mkdir ~/Documents/notes`或`mkdir /tmp/temp_files`)。 若需创建多层嵌套文件夹(如`a/b/c`),普通`mkdir`会因父目录不存在报错,此时需加`-p`选项(`--parents`)自动创建所有父目录(如`mkdir -p workspace/code/python`)。 常见问题:父目录不存在时,用`-p`解决;权限不足则需用`sudo`(谨慎使用)。 总结:`mkdir`核心语法为`mkdir [选项] 路径`,基本创建单个目录,多层目录需`-p`,权限问题用`sudo`。

Read More
Linux Server Basics: From Installation to Network Configuration

This article introduces the basics of Linux servers, covering core steps and key skills. Linux servers, based on open - source systems, are suitable for stable service scenarios (such as those adopted by Alibaba Cloud). For beginners, it is recommended to use Ubuntu Server (user - friendly for novices), CentOS Stream (enterprise - level), and Debian (for basic learning). When installing, virtual machines (VMware/VirtualBox) are preferred, and ISO images and resources of 2 cores, 4G memory, and 40G storage are required. Taking Ubuntu as an example, during virtual machine installation, a username and password need to be set, and automatic partitioning should be used. The core of the system is the command - line interface. Basic commands such as `ls` (list files), `cd` (change directory), and `sudo` (elevate privileges) are commonly used. For network configuration, a static IP needs to be set (CentOS modifies the network card file, while Ubuntu uses Netplan), and ports 80 and 22 should be opened. After installing the SSH service (sshd for CentOS and ssh for Ubuntu), remote connections can be made using Xshell on Windows, or directly via the `ssh` command on Linux/macOS. Key steps include: choosing a distribution → installing in a virtual machine → basic commands → network configuration → SSH connection. Beginners are advised to further study permission management, deploying services such as Nginx, and system monitoring tools. For issues, they can refer to the `man` manual or official documentation.

Read More